<template>
    <!--<el-form :model="ruleForm">
        <el-descriptions column="3" direction="vertical" border>
            <el-descriptions-item label="学号" prop="num">1</el-descriptions-item>
            <el-descriptions-item label="姓名" prop="name">{{stu_name}}</el-descriptions-item>
            <el-descriptions-item label="性别" prop="sex">{{stu_sex}}</el-descriptions-item>
            <el-descriptions-item label="年龄" prop="age">{{stu_age}}</el-descriptions-item>
            <el-descriptions-item label="电话号码" prop="phone">{{stu_phone}}</el-descriptions-item>
            <el-descriptions-item label="校区" prop="address">{{stu_address}}</el-descriptions-item>
            <el-descriptions-item label="专业" prop="major">wu</el-descriptions-item>
            <el-descriptions-item label="年级" prop="grade">{{stu_grade}}</el-descriptions-item>
        </el-descriptions>
        <el-descriptions>
            <el-descriptions-item label="预约时间">
                <el-col :span="11">
                    <el-form-item prop="date">
                        <el-date-picker type="datetime" placeholder="选择日期和时间" v-model="ruleForm.date"></el-date-picker>
                    </el-form-item>
                </el-col>
            </el-descriptions-item>
        </el-descriptions>
        <el-descriptions column="1" direction="vertical" border>
            <el-descriptions-item label="1.你觉得目前压力大吗" prop="resource">
                <el-radio-group v-model="ruleForm.resource">
                    <el-radio label="没什么压力"></el-radio>
                    <el-radio label="一般"></el-radio>
                    <el-radio label="压力较大"></el-radio>
                    <el-radio label="快要崩溃"></el-radio>
                </el-radio-group>
            </el-descriptions-item>
            <el-descriptions-item label="2.你觉得自己经常处于哪种状况" prop="resource">
                <el-radio-group v-model="ruleForm.resource1">
                    <el-radio label="快乐"></el-radio>
                    <el-radio label="平稳"></el-radio>
                    <el-radio label="焦虑"></el-radio>
                    <el-radio label="悲观"></el-radio>
                    <el-radio label="其他"></el-radio>
                </el-radio-group>
            </el-descriptions-item>
            <el-descriptions-item label="3.当遇到压力或烦心事时，你通常会" prop="type">
                <el-checkbox-group v-model="ruleForm.type">
                    <el-checkbox label="烦恼郁闷、焦躁不安" name="type"></el-checkbox>
                    <el-checkbox label="失眠多梦" name="type"></el-checkbox>
                    <el-checkbox label="悲观消极" name="type"></el-checkbox>
                    <el-checkbox label="坚强面对，自我调节" name="type"></el-checkbox>
                    <el-checkbox label="沉默寡言" name="type"></el-checkbox>
                    <el-checkbox label="其他" name="type"></el-checkbox>
                </el-checkbox-group>
            </el-descriptions-item>
            <el-descriptions-item label="4.你出现焦虑的原因有哪些" prop="type">
                <el-checkbox-group v-model="ruleForm.type1">
                    <el-checkbox label="学业问题"></el-checkbox>
                    <el-checkbox label="人际关系问题"></el-checkbox>
                    <el-checkbox label="个人前途问题"></el-checkbox>
                    <el-checkbox label="恋爱问题"></el-checkbox>
                    <el-checkbox label="经济问题"></el-checkbox>
                    <el-checkbox label="其他"></el-checkbox>
                </el-checkbox-group>
            </el-descriptions-item>
            <el-descriptions-item label="5.遇到困扰你一般会向谁请教" prop="type">
                <el-checkbox-group v-model="ruleForm.type2">
                    <el-checkbox label="家人"></el-checkbox>
                    <el-checkbox label="亲友"></el-checkbox>
                    <el-checkbox label="男/女朋友"></el-checkbox>
                    <el-checkbox label="知心朋友"></el-checkbox>
                    <el-checkbox label="老师、学长、学姐"></el-checkbox>
                    <el-checkbox label="专业人员"></el-checkbox>
                    <el-checkbox label="不找"></el-checkbox>
                </el-checkbox-group>
            </el-descriptions-item>
            <el-descriptions-item label="6.你认为自己的交友状况如何" prop="resource">
                <el-radio-group v-model="ruleForm.resource2">
                    <el-radio label="非常好，交友满天下"></el-radio>
                    <el-radio label="有很多朋友，但没几个知心朋友"></el-radio>
                    <el-radio label="朋友不多，有几个知心的就行"></el-radio>
                    <el-radio label="不善交际，没什么朋友"></el-radio>
                </el-radio-group>
            </el-descriptions-item>
            <el-descriptions-item label="7.心理自述:" prop="desc">
                <el-input type="textarea" v-model="ruleForm.desc"></el-input>
            </el-descriptions-item>
        </el-descriptions>
        <el-descriptions>
            <el-descriptions-item>
                <el-button type="primary">立即创建</el-button>
                <el-button @click="resetForm('ruleForm')">重置</el-button>
            </el-descriptions-item>
        </el-descriptions>
    </el-form>-->
    <div>
        <!--用户的基本信息-->
        <el-descriptions class="margin-top" :column="3" border>
            <el-descriptions-item>
                <template slot="label">
                    <i class="el-icon-user"></i>
                    姓名
                </template>
                {{ userInfo.stuName }}
            </el-descriptions-item>
            <el-descriptions-item>
                <template slot="label">
                    <i class="el-icon-office-building"></i>
                    学号
                </template>
                {{ userInfo.stuNum }}
            </el-descriptions-item>
            <el-descriptions-item>
                <template slot="label">
                    <i class="el-icon-office-building"></i>
                    性别
                </template>
                {{ userInfo.stuSex == 1 ? '男' : '女' }}
            </el-descriptions-item>
            <el-descriptions-item>
                <template slot="label">
                    <i class="el-icon-mobile-phone"></i>
                    手机号
                </template>
                {{ userInfo.stuPhone }}
            </el-descriptions-item>
            <el-descriptions-item>
                <template slot="label">
                    <i class="el-icon-location-outline"></i>
                    校区
                </template>
                {{ userInfo.stuAddress }}
            </el-descriptions-item>
            <el-descriptions-item>
                <template slot="label">
                    <i class="el-icon-tickets"></i>
                    专业
                </template>
                {{ userInfo.stuMajor }}
            </el-descriptions-item>
        </el-descriptions>
        <!--进行申请预约操作-->
        <el-form ref="form" :model="submitInfo" label-width="80px">
            <el-descriptions :column="1" direction="vertical" border>
                <el-descriptions-item label="预约周数">
                    <el-select v-model="submitInfo.visitDate" placeholder="请选择预约周数">
                        <el-option value="周一"></el-option>
                        <el-option value="周二"></el-option>
                        <el-option value="周三"></el-option>
                        <el-option value="周四"></el-option>
                        <el-option value="周五"></el-option>
                    </el-select>
                </el-descriptions-item>
                <el-descriptions-item label="预约时间">
                    <el-select v-model="submitInfo.visitTime" placeholder="请选择预约时间">
                        <el-option value="8:00-10:00"></el-option>
                        <el-option value="10:00-12:00"></el-option>
                        <el-option value="14:00-16:00"></el-option>
                        <el-option value="16:00-18:00"></el-option>
                    </el-select>
                </el-descriptions-item>
                <el-descriptions-item label="1.你觉得目前压力大吗">
                    <el-radio-group v-model="ruleForm.resource">
                        <el-radio :label="0">没什么压力</el-radio>
                        <el-radio :label="1">一般</el-radio>
                        <el-radio :label="2">压力较大</el-radio>
                        <el-radio :label="3">快要崩溃</el-radio>
                    </el-radio-group>
                </el-descriptions-item>
                <el-descriptions-item label="2.你觉得自己经常处于哪种状况" >
                    <el-radio-group v-model="ruleForm.resource1">
                        <el-radio :label="0">快乐</el-radio>
                        <el-radio :label="1">平稳</el-radio>
                        <el-radio :label="2">焦虑</el-radio>
                        <el-radio :label="3">悲观</el-radio>
                    </el-radio-group>
                </el-descriptions-item>
                <el-descriptions-item label="3.当遇到压力或烦心事时，你通常会">
                    <el-checkbox-group v-model="ruleForm.type">
                        <el-checkbox :label="20" >烦恼郁闷、焦躁不安</el-checkbox>
                        <el-checkbox :label="15" >失眠多梦</el-checkbox>
                        <el-checkbox :label="10" >悲观消极</el-checkbox>
                        <el-checkbox :label="0" >坚强面对，自我调节</el-checkbox>
                        <el-checkbox :label="5" >沉默寡言</el-checkbox>
                    </el-checkbox-group>
                </el-descriptions-item>
                <el-descriptions-item label="4.你出现焦虑的原因有哪些">
                    <el-checkbox-group v-model="ruleForm.type1">
                        <el-checkbox :label="5" >学业问题</el-checkbox>
                        <el-checkbox :label="10" >人际关系问题</el-checkbox>
                        <el-checkbox :label="15" >个人前途问题</el-checkbox>
                        <el-checkbox :label="4" >恋爱问题</el-checkbox>
                        <el-checkbox :label="12" >经济问题</el-checkbox>
                        <el-checkbox :label="10">其他</el-checkbox>
                    </el-checkbox-group>
                </el-descriptions-item>
                <el-descriptions-item label="5.遇到困扰你一般会向谁请教">
                    <el-checkbox-group v-model="ruleForm.type2">
                        <el-checkbox :label="3" >家人</el-checkbox>
                        <el-checkbox :label="5" >亲友</el-checkbox>
                        <el-checkbox :label="4" >男/女朋友</el-checkbox>
                        <el-checkbox :label="2" >知心朋友</el-checkbox>
                        <el-checkbox :label="6" >老师、学长、学姐</el-checkbox>
                        <el-checkbox :label="1" ></el-checkbox>专业人员</el-checkbox>
                        <el-checkbox :label="10">不找</el-checkbox>
                    </el-checkbox-group>
                </el-descriptions-item>
                <el-descriptions-item label="6.你认为自己的交友状况如何">
                    <el-radio-group v-model="ruleForm.resource2" >
                        <el-radio :label="0">非常好，交友满天下</el-radio>
                        <el-radio :label="10">有很多朋友，但没几个知心朋友</el-radio>
                        <el-radio :label="5">朋友不多，有几个知心的就行</el-radio>
                        <el-radio :label="15">不善交际，没什么朋友</el-radio>
                    </el-radio-group>
                </el-descriptions-item>
                <el-descriptions-item label="7.心理自述:" prop="userCrisisText">
                    <el-input type="textarea" v-model="submitInfo.userCrisisText"></el-input>
                </el-descriptions-item>
            </el-descriptions>
            <el-descriptions>
                <el-descriptions-item>
                    <el-button type="primary" @click="submitForm()">立即创建</el-button>
                </el-descriptions-item>
            </el-descriptions>
        </el-form>
    </div>
</template>

<script>
import {reqAddInit} from '@/api/InitiaVisit'
export default {
    data() {
        return {
            ruleForm: {
                type: [],
                type1: [],
                type2: [],
                resource: '',
                resource1: '',
                resource2: '',
            },
            userInfo: {},
            submitInfo: {
                stuId: '',
                stuNum: '',
                visitCrisisGrades: [],
                visitTime: '',
                visitDate: '',
                userCrisisText: '',
            }
        }
    },
    methods: {
        async submitForm() {
            /*this.$refs[formName].validate((valid) => {
                if (valid) {
                    alert('submit!');
                } else {
                    console.log('error submit!!');
                    return false;
                }
            });*/
            let {type,type1,type2,resource,resource1,resource2} =this.ruleForm
            this.submitInfo.stuId = this.userInfo.stuId;
            this.submitInfo.stuNum = this.userInfo.stuNum;
            let num=0
            for(let i=0;i<type.length;i++){
                num+=type[i]
            };
            for(let i=0;i<type1.length;i++){
                num+=type1[i]
            };
            for(let i=0;i<type2.length;i++){
                num+=type2[i]
            }
            this.submitInfo.visitCrisisGrades=resource+resource1+resource+num
            let result=await reqAddInit(this.submitInfo)
            if(result.code==0){
                this.$message({
                    message:'申请成功',
                    type:'success'
                })
            }
        },
        /*resetForm(formName) {
            this.$refs[formName].resetFields();
            this.$refs[this.submitIndo].resetFields();
        }*/
    },
    mounted() {
        console.log(this.$store.state.userInfo);
        this.userInfo = this.$store.state.userInfo
    }
}
</script>

<style scoped></style>